package com.xhh.nphm.web.controller.system;

import com.xhh.nphm.common.core.controller.BaseController;
import com.xhh.nphm.common.core.domain.AjaxResult;
import com.xhh.nphm.common.core.page.TableDataInfo;
import com.xhh.nphm.system.domain.*;
import com.xhh.nphm.system.service.TmSensitiveActionService;
import com.xhh.nphm.system.service.TmSensitiveAddressService;
import com.xhh.nphm.system.service.TmSensitiveObjectService;
import com.xhh.nphm.system.service.TmSensitiveTimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * 特殊对象控制器类
 * @author zz
 */
@RestController
@RequestMapping("/system/specialObj")
public class SysSpecialObjController extends BaseController {
    private final String prefix = "/system/specialObj";

    @Autowired
    private TmSensitiveActionService actionService;
    @Autowired
    private TmSensitiveAddressService addressService;
    @Autowired
    private TmSensitiveTimeService timeService;
    @Autowired
    private TmSensitiveObjectService objectService;

    /**
     * 进入特殊时间列表页面
     * @return 模型与视图对象
     */
    @GetMapping("/specialTime")
    public ModelAndView specialTime(){
        return new ModelAndView(prefix + "/specialTime");
    }

    /**
     * 进入特殊地点列表页面
     * @return 模型与视图对象
     */
    @GetMapping("/specialAddress")
    public ModelAndView specialAddress(){
        return new ModelAndView(prefix + "/specialAddress");
    }

    /**
     * 进入特殊行为列表页面
     * @return 模型与视图对象
     */
    @GetMapping("/specialAction")
    public ModelAndView specialAction(){
        return new ModelAndView(prefix + "/specialAction");
    }

    /**
     * 进入特殊行为列表页面
     * @return 模型与视图对象
     */
    @GetMapping("/specialObj")
    public ModelAndView specialObj(){
        return new ModelAndView(prefix + "/specialObj");
    }

    /**
     * 进入特殊时间新增页面
     * @return 模型与视图对象
     */
    @GetMapping("/specialTime/add")
    public ModelAndView specialTimeAdd(){
        return new ModelAndView(prefix + "/specialTimeAdd");
    }

    /**
     * 新增特殊时间
     * @param sensitiveTime 特殊时间实体
     * @return 结果
     */
    @PostMapping("/specialTime/add")
    public AjaxResult specialTimeAdd(TmSensitiveTime sensitiveTime){
        return toAjax(timeService.save(sensitiveTime));
    }

    /**
     * 进入特殊时间修改页面
     * @return 模型与视图对象
     */
    @GetMapping("/specialTime/edit/{id}")
    public ModelAndView specialTimeEdit(@PathVariable("id") Integer pkId, ModelAndView mav){
        mav.addObject("specialTime",timeService.getById(pkId));
        mav.setViewName(prefix + "/specialTimeEdit");
        return mav;
    }

    /**
     * 修改特殊时间
     * @param sensitiveTime 特殊时间实体
     * @return 结果
     */
    @PostMapping("/specialTime/edit")
    public AjaxResult specialTimeEdit(TmSensitiveTime sensitiveTime){
        return toAjax(timeService.updateById(sensitiveTime));
    }

    /**
     * 删除特殊时间
     * @return 响应结果
     */
    @PostMapping("/specialTime/remove/{id}")
    public AjaxResult specialTimeRemove(@PathVariable("id") Integer pkId){
        return toAjax(timeService.removeById(pkId));
    }


    /**
     * 进入特殊地点新增页面
     * @return 模型与视图对象
     */
    @GetMapping("/specialAddress/add")
    public ModelAndView specialAddressAdd(){
        return new ModelAndView(prefix + "/specialAddressAdd");
    }

    /**
     * 新增特殊地点
     * @param sensitiveAddress 特殊地点实体
     * @return 结果
     */
    @PostMapping("/specialAddress/add")
    public AjaxResult specialAddressAdd(TmSensitiveAddress sensitiveAddress){
        return toAjax(addressService.save(sensitiveAddress));
    }

    /**
     * 进入特殊地点修改页面
     * @return 模型与视图对象
     */
    @GetMapping("/specialAddress/edit/{id}")
    public ModelAndView specialAddressEdit(@PathVariable("id") Integer pkId, ModelAndView mav){
        mav.addObject("specialAddress",addressService.getById(pkId));
        mav.setViewName(prefix + "/specialAddressEdit");
        return mav;
    }

    /**
     * 修改特殊地点
     * @param sensitiveAddress 特殊地点实体
     * @return 结果
     */
    @PostMapping("/specialAddress/edit")
    public AjaxResult specialAddressEdit(TmSensitiveAddress sensitiveAddress){
        return toAjax(addressService.updateById(sensitiveAddress));
    }

    /**
     * 删除特殊地点
     * @return 响应结果
     */
    @PostMapping("/specialAddress/remove/{id}")
    public AjaxResult specialAddressRemove(@PathVariable("id") Integer pkId){
        return toAjax(addressService.removeById(pkId));
    }

    /**
     * 进入特殊行为新增页面
     * @return 模型与视图对象
     */
    @GetMapping("/specialAction/add")
    public ModelAndView specialActionAdd(){
        return new ModelAndView(prefix + "/specialActionAdd");
    }

    /**
     * 新增特殊行为
     * @param sensitiveAction 特殊行为实体
     * @return 结果
     */
    @PostMapping("/specialAction/add")
    public AjaxResult specialActionAdd(TmSensitiveAction sensitiveAction){
        return toAjax(actionService.save(sensitiveAction));
    }

    /**
     * 进入特殊行为修改页面
     * @return 模型与视图对象
     */
    @GetMapping("/specialAction/edit/{id}")
    public ModelAndView specialActionEdit(@PathVariable("id") Integer pkId, ModelAndView mav){
        mav.addObject("specialAction",actionService.getById(pkId));
        mav.setViewName(prefix + "/specialActionEdit");
        return mav;
    }

    /**
     * 修改特殊行为
     * @param sensitiveAction 特殊行为实体
     * @return 结果
     */
    @PostMapping("/specialAction/edit")
    public AjaxResult specialActionEdit(TmSensitiveAction sensitiveAction){
        return toAjax(actionService.updateById(sensitiveAction));
    }

    /**
     * 删除特殊行为
     * @return 响应结果
     */
    @PostMapping("/specialAction/remove/{id}")
    public AjaxResult specialActionRemove(@PathVariable("id") Integer pkId){
        return toAjax(actionService.removeById(pkId));
    }

    /**
     * 进入特殊对象新增页面
     * @return 模型与视图对象
     */
    @GetMapping("/specialObj/add")
    public ModelAndView specialObjAdd(){
        return new ModelAndView(prefix + "/specialObjAdd");
    }

    /**
     * 新增特殊对象
     * @param sensitiveObj 特殊行为实体
     * @return 结果
     */
    @PostMapping("/specialObj/add")
    public AjaxResult specialObjAdd(TmSensitiveObject sensitiveObj){
        return toAjax(objectService.save(sensitiveObj));
    }

    /**
     * 进入特殊对象修改页面
     * @return 模型与视图对象
     */
    @GetMapping("/specialObj/edit/{id}")
    public ModelAndView specialObjEdit(@PathVariable("id") Integer pkId, ModelAndView mav){
        mav.addObject("specialObj",objectService.getById(pkId));
        mav.setViewName(prefix + "/specialObjEdit");
        return mav;
    }

    /**
     * 修改特殊对象
     * @param sensitiveObj 特殊行为实体
     * @return 结果
     */
    @PostMapping("/specialObj/edit")
    public AjaxResult specialObjEdit(TmSensitiveObject sensitiveObj){
        return toAjax(objectService.updateById(sensitiveObj));
    }

    /**
     * 删除特殊对象
     * @return 响应结果
     */
    @PostMapping("/specialObj/remove/{id}")
    public AjaxResult specialObjRemove(@PathVariable("id") Integer pkId){
        return toAjax(objectService.removeById(pkId));
    }


    /**
     * 加载特殊时间列表数据
     * @return 列表数据
     */
    @PostMapping("/specialTimeJson")
    public TableDataInfo specialTimeJson(TmSensitiveTime sensitiveTime) {
        startPage();
        List<TmSensitiveTime> list = timeService.listJson(sensitiveTime);
        return getDataTable(list);
    }

    /**
     * 加载特殊地点列表数据
     * @return 列表数据
     */
    @PostMapping("/specialAddressJson")
    public TableDataInfo specialAddressJson(TmSensitiveAddress sensitiveAddress) {
        startPage();
        List<TmSensitiveAddress> list = addressService.listJson(sensitiveAddress);
        return getDataTable(list);
    }

    /**
     * 加载特殊行为列表数据
     * @return 列表数据
     */
    @PostMapping("/specialActionJson")
    public TableDataInfo specialActionJson(TmSensitiveAction sensitiveAction) {
        startPage();
        List<TmSensitiveAction> list = actionService.listJson(sensitiveAction);
        return getDataTable(list);
    }

    /**
     * 加载特殊对象列表数据
     * @return 列表数据
     */
    @PostMapping("/specialObjJson")
    public TableDataInfo specialObjJson(TmSensitiveObject sensitiveObject) {
        startPage();
        List<TmSensitiveObject> list = objectService.listJson(sensitiveObject);
        return getDataTable(list);
    }


}
